﻿using DapperForCoreDemo.Service;
using Microsoft.AspNetCore.Mvc;

namespace DapperForCoreDemo.Controllers
{
    /// <summary>
    /// demo01
    /// </summary>
    [Route("api/v1")]
    public class Demo01Controller : Controller
    {
        //服务
        private Demo01Service _db;
        /// <summary>
        /// 默认
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 获取商品信息
        /// </summary>
        /// <returns>商品列表</returns>
        [HttpGet("goods/list")]
        public JsonResult GetGoodsList()
        {
            string sql = "select * from goods";
            return new JsonResult(_db.GetGoods(sql));
        }
    }
}